package com.tom.architect02.ui20.day18;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
 * Added by Tom on 2024/06/18.
 */
public class MyScrollView extends ScrollView {

    public MyScrollView(Context context) {
        super(context);
    }

    public MyScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        if (mListener != null) {
            mListener.onScroll(l, t, oldl, oldt);
        }
    }

    private ScrollChangeListener mListener;
    public interface ScrollChangeListener {
        void onScroll(int l, int t, int oldl, int oldt);
    }
    public void setOnScrollChangeListener(ScrollChangeListener listener) {
        this.mListener = listener;
    }
}
